package com.gyy.GeneralFunction;

import com.gyy.Alarm.ThermometryAlarm;
import com.gyy.sdk.HCNetSDK;

/**
 * @Author Qiu Jiahang
 * @Date 2021/4/7 11:35
 */
public class Logout {

    static HCNetSDK hCNetSDK = HCNetSDK.INSTANCE;

    /**
     * 登出操作
     *
     * @param thermometryAlarm 传入报警监听句柄
     */
    public void Logout(ThermometryAlarm thermometryAlarm, int lUserID) {

        if (lUserID >= 0) {
            /**退出之前判断布防监听状态，并做撤防和停止监听操作*/
            if (thermometryAlarm.lAlarmHandle >= 0) {
                if (!hCNetSDK.NET_DVR_CloseAlarmChan_V30(thermometryAlarm.lAlarmHandle)) {
                    System.out.println("撤防失败，错误码：" + hCNetSDK.NET_DVR_GetLastError());
                } else {
                    System.out.println("撤防成功！！！");
                }
            }
            if (thermometryAlarm.lListenHandle >= 0) {
                if (!hCNetSDK.NET_DVR_StopListen_V30(thermometryAlarm.lListenHandle)) {
                    System.out.println("取消监听失败，错误码：" + hCNetSDK.NET_DVR_GetLastError());
                } else {
                    System.out.println("停止监听成功！！！");
                }
            }

            /**登出和清理，释放SDK资源*/
            if (hCNetSDK.NET_DVR_Logout(lUserID)) {
                System.out.println("登出成功！！！");
            }
        }
        hCNetSDK.NET_DVR_Cleanup();
    }
}
